<include file="Public/header"/>
<include file="Public/menu"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/bootstrap-switch.min.css">
<div class="page-content">
	<div class="page-header">
		<h1>
			评论管理
			<small>
				<i class="icon-double-angle-right"></i>
				评论列表
			</small>
		</h1>
	</div>
	<!-- /.page-header -->
	<!-- PAGE CONTENT BEGINS -->
	<div class="row">
		<div class="col-xs-12">
			<div class="row">
				<div class="tabbable">
					<ul class="nav nav-tabs" id="myTab">
						<li class="active">
							<a href="http://localhost/vivo/Wolf/index.php/Admin/Comment/index">
								<i class="green icon-home bigger-110"></i>
								用户列表
							</a>
						</li>

					</ul>
					<div class="tab-content">
						<div class="tab-pane in active">
							<div class="table-responsive">
								<table id="sample-table" class="table table-striped table-bordered table-hover">
									<thead>
									<tr>
										<th class="center">ID</th>
										<th>评论内容</th>
										<th>评论者ID</th>
										<th>添加时间</th>
										<th>状态</th>
									</tr>
									</thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- PAGE CONTENT END -->
</div>
</div>
</div>

<script type="text/javascript">
	seajs.use(['admin-common','$','dataTables',"dataTables-bootstrap", 'bootbox','bootstrap-switch'],function(admin,$){
		var oTable = $('#sample-table').dataTable({
			"aaSorting" : [[5, "desc"]], //默认的排序方式，第6列，降序排列
			"bAutoWidth" : false,//是否自适应宽度
			"aLengthMenu" : [[10, 25, 50, 100], [10, 25, 50, 100]],//每页显示数据量
			"aoColumns" : [ //列操作
				{"sClass" : "center", "mData" : "id","sWidth" : "10%"},
				{"mData" : "content",bSortable:false},
				{"mData" : "uid","sWidth" : "10%",bSortable:false},
				{
					"mData" : "addtime",
					"sWidth" : "10%",
					"mRender" : function (data) {
						return  admin.format(data*1000,"yy年MM月dd日");
					}
				},

				{
					"sWidth" : "10%",
					"sClass" : "center",
					"mData" : "status",
					"mRender" : function (data, type, full) {
						var res = "";
						var id = full.id;
						if (full.status == 1 ) {
							res = "<div class='switch switch-small'><input name='switch' type='checkbox' data-size='small' data-on-text='开启' data-off-text='禁用' data-on-color='success' data-off-color='danger' checked  data-id="+id+"></div>";
						}else{
							res = "<div class='switch switch-small'><input name='switch' type='checkbox' data-size='small' data-on-text='开启' data-off-text='禁用' data-on-color='success' data-off-color='danger'  data-id="+id+" ></div>";
						}
						return res;
					}
				},
			],
			//与服务器端传输数据
			"bServerSide" : true,//服务端处理分页
			"sAjaxSource" : "/vivo/Wolf/index.php/Admin/Comment/commentList",
			"sServerMethod" : "POST",
			//"bProcessing": true,

			//多语言配置
			"oLanguage" : {
				"sProcessing" : "正在加载中......",
				"sLengthMenu" : "每页显示 _MENU_ 条记录",
				"sZeroRecords" : "对不起，查询不到相关数据！",
				"sEmptyTable" : "表中无数据存在！",
				"sInfo" : "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
				"sInfoFiltered" : "数据表中共为 _MAX_ 条记录",
				"sSearch" : "搜索",
				"oPaginate" : {
					"sFirst" : "首页",
					"sPrevious" : "上一页",
					"sNext" : "下一页",
					"sLast" : "末页"
				}
			},
			"fnDrawCallback":function(){
			$("[name='switch']").bootstrapSwitch().on('switchChange', function(e, data) {
				var id = $(this).attr('data-id');
				var status = data.value ? 1 : 2;
				$.ajax({
					url:"/vivo/Wolf/index.php/Admin/Comment/update",
					data:{status:status ,id:id},
					type:'post',
				})
			});
		}
		}
		);

	});

</script>

<include file="Public/footer"/>

</body></html>